package com.ruiben.mall.controller;


import com.ruiben.mall.impl.CollectionServiceImpl;
import com.ruiben.mall.impl.ProductServiceImpl;
import com.ruiben.mall.pojo.ShopProduct;
import com.ruiben.mall.pojo.UserCollection;
import com.ruiben.mall.utils.CommonJSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("collec")
@RestController
public class CollectionController {

    @Autowired
    private CollectionServiceImpl collectionService;

    @PostMapping("collGoods")
    public CommonJSONResult collecGoods(String goodsId,String userId) {
        UserCollection userCollection = new UserCollection();
        userCollection.setProductId(goodsId);
        userCollection.setUserid(userId);

        boolean b = collectionService.collGoods(userCollection);
        if (b) {
            return CommonJSONResult.ok();
        }

        return CommonJSONResult.errorMsg("收藏失败");

    }

}
